<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        prop="id"
        header-align="center"
        align="center"
        label="产品信息id">
      </el-table-column>
      <el-table-column
        prop="productId"
        header-align="center"
        align="center"
        label="产品id">
      </el-table-column>
      <el-table-column
        prop="productName"
        header-align="center"
        align="center"
        label="产品名称">
      </el-table-column>
      <el-table-column
        prop="model"
        header-align="center"
        align="center"
        label="产品型号">
      </el-table-column>
      <el-table-column
        prop="coveredModels"
        header-align="center"
        align="center"
        label="涵盖机型">
      </el-table-column>
      <el-table-column
        prop="manufacturer"
        header-align="center"
        align="center"
        label="生产者名称">
      </el-table-column>
      <el-table-column
        prop="manufacturerAddress"
        header-align="center"
        align="center"
        label="生产者的注册地址">
      </el-table-column>
      <el-table-column
        prop="manufacturerPhone"
        header-align="center"
        align="center"
        label="生产者电话">
      </el-table-column>
      <el-table-column
        prop="manufacturerFax"
        header-align="center"
        align="center"
        label="生产者传真">
      </el-table-column>
      <el-table-column
        prop="manufacturerContact"
        header-align="center"
        align="center"
        label="生产者联系人">
      </el-table-column>
      <el-table-column
        prop="manufacturerZipcode"
        header-align="center"
        align="center"
        label="生产者邮政编码">
      </el-table-column>
      <el-table-column
        prop="factory"
        header-align="center"
        align="center"
        label="生产厂名称">
      </el-table-column>
      <el-table-column
        prop="factoryAddress"
        header-align="center"
        align="center"
        label="生产厂的注册地址">
      </el-table-column>
      <el-table-column
        prop="factoryPhone"
        header-align="center"
        align="center"
        label="生产厂电话">
      </el-table-column>
      <el-table-column
        prop="factoryFax"
        header-align="center"
        align="center"
        label="生产厂传真">
      </el-table-column>
      <el-table-column
        prop="factoryContact"
        header-align="center"
        align="center"
        label="生产厂联系人">
      </el-table-column>
      <el-table-column
        prop="factoryZipcode"
        header-align="center"
        align="center"
        label="生产厂邮政编码">
      </el-table-column>
      <el-table-column
        prop="judgmentBasis"
        header-align="center"
        align="center"
        label="鉴定依据的标准">
      </el-table-column>
      <el-table-column
        prop="judgmentConclusion"
        header-align="center"
        align="center"
        label="鉴定结论">
      </el-table-column>
      <el-table-column
        prop="issueDate"
        header-align="center"
        align="center"
        label="鉴定报告的签发日期">
      </el-table-column>
      <el-table-column
        prop="remark"
        header-align="center"
        align="center"
        label="备注">
      </el-table-column>
      <el-table-column
        prop="reprotStatus"
        header-align="center"
        align="center"
        label="报告状态">
      </el-table-column>
      <el-table-column
        prop="approver"
        header-align="center"
        align="center"
        label="批准人">
      </el-table-column>
      <el-table-column
        prop="approvalOpinion"
        header-align="center"
        align="center"
        label="批准人意见">
      </el-table-column>
      <el-table-column
        prop="auditor"
        header-align="center"
        align="center"
        label="审核人">
      </el-table-column>
      <el-table-column
        prop="auditOpinion"
        header-align="center"
        align="center"
        label="审核人意见">
      </el-table-column>
      <el-table-column
        prop="dateOfApproval"
        header-align="center"
        align="center"
        label="审核日期">
      </el-table-column>
      <el-table-column
        prop="projectLeader"
        header-align="center"
        align="center"
        label="项目负责人">
      </el-table-column>
      <el-table-column
        prop="projectLeaderOpinion"
        header-align="center"
        align="center"
        label="项目负责人意见">
      </el-table-column>
      <el-table-column
        prop="projectLeaderDate"
        header-align="center"
        align="center"
        label="项目负责人填写日期">
      </el-table-column>
      <el-table-column
        prop="pictureProductName"
        header-align="center"
        align="center"
        label="样品图片(产品名称)">
      </el-table-column>
      <el-table-column
        prop="pictureModel"
        header-align="center"
        align="center"
        label="样品图片(产品型号)">
      </el-table-column>
      <el-table-column
        prop="remarks"
        header-align="center"
        align="center"
        label="备注信息">
      </el-table-column>
      <el-table-column
        prop="reportWriter"
        header-align="center"
        align="center"
        label="报告编写人">
      </el-table-column>
      <el-table-column
        prop="reportDate"
        header-align="center"
        align="center"
        label="报告编写日期">
      </el-table-column>
      <el-table-column
        prop="reportChecker"
        header-align="center"
        align="center"
        label="报告校核人">
      </el-table-column>
      <el-table-column
        prop="reportCheckerOpinion"
        header-align="center"
        align="center"
        label="报告校核意见">
      </el-table-column>
      <el-table-column
        prop="reportCheckerDate"
        header-align="center"
        align="center"
        label="报告校核日期">
      </el-table-column>
      <el-table-column
        prop="productFilePath"
        header-align="center"
        align="center"
        label="产品文件路径">
      </el-table-column>
      <el-table-column
        prop="pdfPath"
        header-align="center"
        align="center"
        label="pdf路径">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </div>
</template>

<script>
  import AddOrUpdate from './productinfo-add-or-update'
  export default {
    name : "productInfo",
    data () {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    components: {
      AddOrUpdate
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/reportApproval/productinfo/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/reportApproval/productinfo/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>
